package top.sjydzq.www.controller.Management;

import org.springframework.web.servlet.HandlerInterceptor;
import top.sjydzq.www.bean.Admin;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class AdminInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
        HttpSession session = request.getSession();
        Admin admin = (Admin) session.getAttribute("admin");

        if (admin != null) {
            return true;
        }

        response.sendRedirect("/management/login");

        return false;
    }
}
